<template>
	<loading-page v-if="data.loading" />
	<web-view v-if="data.webview.show" :src="data.webview.src"></web-view>
</template>
<script setup>
	import { reactive } from 'vue';
	import { onShow,onHide } from '@dcloudio/uni-app';
	import { useStore } from 'vuex';
	import config from '@/uni.config.js';
	const store = useStore();
	onShow(() => {
		data.webview.src = `${config.host.openapi}/html/chat/index#/pages/message/message?platform=crm&color=${encodeURIComponent('#E1835B')}&token=${store.getters.token?store.getters.token:1}&navurl=${encodeURIComponent('/subpages/chat/chat')}&loginurl=${encodeURIComponent('/pages/mine/mine')}&random=${Math.random()}`
		setTimeout(() => {
			data.webview.show = true;
		}, 100)
	})
	onHide(()=>{
		setTimeout(()=>{
			uni.$emit('loginLose');
		},200)
	});
	const data = reactive({
		loading: true,
		webview: {
			src: '',
			show: false
		}
	})
</script>
<style scoped lang="scss">
</style>
